#ifndef PROJECTDATABASAOPERATIONS_H
#define PROJECTDATABASAOPERATIONS_H

#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>

extern bool connectProjectDB(QString dbName);

extern void closeProjectDB();

extern void removeProjectDB();
    
extern bool initProjectDB();

extern QVariant getBySql(QString sql);
    
extern int getBuildingID();

extern int getDeviceID();

extern int getAddressID();

extern int isValueExist(int value, int type);
    
extern bool addBuilding(int buildingID, QString buildingName, QString buildingDescribe, int num,
                        int upID, int type);
    
extern bool addDevice(int deviceID, int buildingID, QString name, QString PA, QString appProgram, int adr, int prg, 
                      int par, int grp, int cfg, QString manufacturers, QString orderNum, 
                      QString product, QString unitType, QString manufacturesData, QString version);

extern bool addAddress(int addressID, int value, QString name, QString describe, int upID, 
                       QString address, int type);
    
extern bool deleteBuildingByID(int buildingID);

extern bool deleteBuildingByName(QString name);
    
extern bool deleteDeviceByID(int deviceID);

extern bool deleteAddressByID(int addressID);

extern bool deleteAddressByAddress(QString address);
    
extern bool updateBuildingName(int buildingID, QString buildingName);

extern QString getBuilgingNameByID(int buildingID);

extern bool updateBuildingDescribe(int buildingID, QString describe);

extern bool updateBuildingNum(int buildingID, int num);

extern bool updateDeviceName(int deviceID, QString deviceName);

extern bool updateDeviceDescribe(int deviceID, QString describe);

extern bool updateAddressName(int addressID, QString addressName);

extern bool updateAddressDescribe(int addressID, QString describe);

#endif // PROJECTDATABASAOPERATIONS_H
